/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Vue;

import Controleur.AccueilListener;
import Controleur.QCMListener;
import Controleur.ScoresListener;
import Modele.Partie;
import Modele.Questionnaire;
import java.applet.Applet;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.io.IOException;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JPanel;

/**
 *
 * @author bahia
 */
public class AppletFenetre extends Applet {

    private Accueil accueil;
    private Partie partie;
    private QCM qcm;
    private TAT tat;
    private Scores score;
    final CardLayout cardLayout = new CardLayout();
    final JPanel content = new JPanel();
    final String[] listContent = {"Accueil", "Jeu", "Score"};
    private JButton boutonValider;

    public AppletFenetre() throws IOException {
        accueil = new Accueil();
        partie = new Partie("", 0, new Questionnaire("qcm"));
        qcm = new QCM(partie);
        tat = new TAT(partie);
        score = new Scores();
        lesOnglets();
    }

    public void lesOnglets() {
        /*
         * L'onglet Accueil
         */
        //Bouton valider
        JButton valider = new JButton("Valider");
        ImageIcon i = new ImageIcon("/Images/check.png");
        valider.setIcon(i);
        
        
        valider.addActionListener(new AccueilListener(this));
        accueil.getPanel_pseudo().add(valider);
        
        JPanel panel_scores = new JPanel();        
        JButton scores = new JButton("Scores");
        panel_scores.add(scores);
        scores.addActionListener(new AccueilListener(this));
        accueil.add(panel_scores);


        /*
         * L'onglet Jeu
         */
        //ajouterBoutonAccueil();
        //ajouterBoutonValiderQuestion();
        
        /*
         * L'onglet Scores
         */
        JButton boutonAccueil = new JButton("Accueil");
        boutonAccueil.addActionListener(new ScoresListener(this));
        score.add(boutonAccueil);

       
        //Configuration des onglets
        content.setLayout(cardLayout);
        content.add(accueil, listContent[0]);
        content.add(qcm, listContent[1]);
        content.add(score, listContent[2]);


        //Disposition de l'application
        this.setLayout(new BorderLayout());
        this.add(content, BorderLayout.CENTER);
    }

    public Accueil getAccueil() {
        return accueil;
    }

    public void setAccueil(Accueil accueil) {
        this.accueil = accueil;
    }

    public QCM getQCM() {
        return qcm;
    }

    public void setQCM(QCM qcm) {
        this.qcm = qcm;
        this.partie = qcm.getPartie();
    }
    
    public TAT getTAT() {
        return tat;
    }

    public void setTAT(TAT tat) {
        this.tat = tat;
        this.partie = tat.getPartie();
    }

    public Scores getScore() {
        return score;
    }

    public void setScore(Scores score) {
        this.score = score;
    }

    public CardLayout getCardLayout() {
        return cardLayout;
    }

    public JPanel getContent() {
        return content;
    }

    public String[] getListContent() {
        return listContent;
    }

    public Partie getPartie() {
        return partie;
    }

    public void setPartie(Partie partie) {
        this.partie = partie;
    }
    
    public void ajouterBoutonAccueil() {
        JButton boutonAccueil = new JButton("Abandonner");
        boutonAccueil.addActionListener(new QCMListener(this));
        qcm.getPanel_bas().add(boutonAccueil);
    }
    
    public void ajouterBoutonValiderQuestion() {
        boutonValider = new JButton("Question suivante");
        boutonValider.addActionListener(new QCMListener(this));
        qcm.getPanel_bas().add(boutonValider);
    }

    public QCM getQcm() {
        return qcm;
    }

    public void setQcm(QCM qcm) {
        this.qcm = qcm;
    }

    public JButton getBoutonValider() {
        return boutonValider;
    }

    public void setBoutonValider(JButton boutonValider) {
        this.boutonValider = boutonValider;
    }
    
    
    
}
